//
//  MainMenuViewController.m
//  Bluetooth Mini Games
//
//  Created by iD Student on 7/15/13.
//  Copyright (c) 2013 ZTBWorks. All rights reserved.
//

#import "MainMenuViewController.h"

@interface MainMenuViewController ()

@end

@implementation MainMenuViewController

@synthesize headerLabel, statusLabel;

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    mainGame = [MainGameViewController alloc];
}

- (IBAction) startOnePlayerGame:(id)sender
{
    SetupGameViewController *viewController = [[SetupGameViewController alloc]init];
    viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"SetupGameView"];
    [self presentViewController:viewController animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
- (IBAction)btnConnect:(id)sender
{
    picker = [[GKPeerPickerController alloc] init];
    picker.delegate = self;
    picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby;
    [picker show];
}

- (void)peerPickerController:(GKPeerPickerController *)picker
              didConnectPeer:(NSString *)peerID
                   toSession:(GKSession *) session {
    ((AppDelegate *)[[UIApplication sharedApplication] delegate]).gameSession = session;
    
    ((AppDelegate *)[[UIApplication sharedApplication] delegate]).gameSession.delegate = self;
    [session setDataReceiveHandler:self withContext:nil];
    picker.delegate = nil;
    [picker dismiss];
}

- (void)peerPickerControllerDidCancel:(GKPeerPickerController *)picker
{
    picker.delegate = nil;
}

- (void)session:(GKSession *)session
           peer:(NSString *)peerID
 didChangeState:(GKPeerConnectionState)state {
    switch (state)
    {
        case GKPeerStateConnected:
            NSLog(@"connected");
            
            mainGame = [[MainGameViewController alloc ]init];
            if([[UIScreen alloc]bounds].size.height == 1136)
            {
                mainGame = [self.storyboard instantiateViewControllerWithIdentifier:@"MainGameViewTall"];
            } else {
                mainGame = [self.storyboard instantiateViewControllerWithIdentifier:@"MainGameViewNormal"];
            }
            [self presentViewController:mainGame animated:YES completion:nil];
            break;
        case GKPeerStateDisconnected:
            NSLog(@"disconnected");
            session = nil;
            break;
        case GKPeerStateAvailable:
        case GKPeerStateConnecting:
        case GKPeerStateUnavailable:
            break;
    }
}

- (void) session:(GKSession *)session didFailWithError:(NSError *)error
{
    NSLog(error.description);
}

- (void) mySendDataToPeers:(NSData *) data
{
    if (((AppDelegate *)[[UIApplication sharedApplication] delegate]).gameSession)
        [((AppDelegate *)[[UIApplication sharedApplication] delegate]).gameSession sendDataToAllPeers:data
                                   withDataMode:GKSendDataReliable
                                          error:nil];
}

- (void) receiveData:(NSData *)data
            fromPeer:(NSString *)peer
           inSession:(GKSession *)session
             context:(void *)context {
    
    //---convert the NSData to NSString---
    NSString* str;
    str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Data received"
                                                    message:str
                                                   delegate:self
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
    [alert show];
    [alert release];
}*/

@end
